package jp.ac.u_tokyo.dch.model.output;

import java.util.ArrayList;
import java.util.List;

public class OutputTag {

	/** 反服サイン */
	private final static String HANHUKU_YES = "1";

	private String tagName;
	private int level;
	private int oyaTagid;

	private List<String> textList = new ArrayList<String>();

	private List<Attribute> attrList = new ArrayList<Attribute>();

	private List<OutputTag> childTagList = new ArrayList<OutputTag>();

	public String getTagName() {
		return tagName;
	}

	public void setTagName(String tagName) {
		this.tagName = tagName;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public int getOyaTagid() {
		return oyaTagid;
	}

	public void setOyaTagid(int oyaTagid) {
		this.oyaTagid = oyaTagid;
	}

	public List<String> getTextList() {
		return textList;
	}

	public void setTextList(List<String> textList) {
		this.textList = textList;
	}

	public List<Attribute> getAttrList() {
		return attrList;
	}

	public void setAttrList(List<Attribute> attrList) {
		this.attrList = attrList;
	}

	public List<OutputTag> getChildTagList() {
		return childTagList;
	}

	public void setChildTagList(List<OutputTag> childTagList) {
		this.childTagList = childTagList;
	}

	public String output() {

		StringBuilder output = new StringBuilder();

		output.append("<");
		output.append(tagName);

		for (Attribute attribute : attrList) {

			output.append(" ");
			output.append(attribute.getName());
			output.append("=");
			output.append("\"");
			output.append(attribute.getValue());
			output.append("\"");
		}
		output.append(">");

		for (String text : textList) {

			output.append(text);
		}

		for (OutputTag child : childTagList) {

			output.append(child.output());
		}

		output.append("</");
		output.append(tagName);
		output.append(">");

		return output.toString();
	}
}
